// Copyright 2024 Innkeeper GoTribe <https://www.gotribe.cn>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file. The original repo for
// this file is https://www.gotribe.cn

// The package model defines the data structures and database mappings for the application.
package model

// Import the gorm package to use its ORM features for database operations.
import (
	"gorm.io/gorm"
)

// TagM represents the database model for tag records, mapping the database table 'tag' to a Go struct.
// This struct includes fields such as TagID, Title, and Description, each annotated with gorm tags to specify database column types and constraints.
type TagM struct {
	gorm.Model         // Embed the gorm.Model to include default fields like ID, CreatedAt, UpdatedAt, and DeletedAt.
	TagID       string `gorm:"type:char(10);uniqueIndex;example:唯一字符ID/分布式ID" json:"tagID"`    // TagID is the unique identifier for a tag, using a CHAR type with a length of 10, and is uniquely indexed.
	Title       string `gorm:"type:varchar(255);uniqueIndex;not null;example:标题" json:"title"` // Title is the name of the tag, using a VARCHAR type with a length of 255, and is uniquely indexed and not null.
	Color       string `gorm:"type:varchar(30);example:颜色" json:"color"`                       // Color is the color associated with the tag, using a VARCHAR type with a length of 30.
	Description string `gorm:"not null;size:300;example:描述" json:"description"`                // Description provides a detailed explanation of the tag, with a maximum length of 300 characters and is not null.
}

// TableName specifies the name of the database table that the TagM struct corresponds to.
// This function overrides the default table name generated by gorm, explicitly setting it to 'tag'.
func (m *TagM) TableName() string {
	return "tag"
}
